(function (mui, $) {
	var sexConfig = [
		{text: '请选择', value: 0},
		{text: '男', value: 1},
		{text: '女', value: 2}
	];
	
	var user_realnameInput = $('.user_realname');
	var sexInput = $('.sex');
	var birthdayInput = $('.birthday');
	var mobileInput = $('.mobile');
	
	user_realnameInput.val(userInfo.user_realname);
	sexInput.text(sexConfig[userInfo.sex].text);
	birthdayInput.text(userInfo.birthday || '');
	mobileInput.val(userInfo.mobile);
	
    var dtPicker = new mui.DtPicker({
	    	type:'date',
	    	beginYear: (new Date()).getYear() - 80
    	});
    var picker = new mui.PopPicker();
    
	var formdata = {
		user_realname: userInfo.user_realname,
		sex: userInfo.sex,
		birthday: userInfo.birthday,
		mobile: userInfo.mobile
	};
    
    // 性别选择
    sexInput.parent().on('tap', function () {
    	picker.setData(sexConfig);
	    picker.show(function (item) {
	    	item = item[0];
	    	sexInput.text(item.text);
	    	formdata.sex = item.value;
	    });
    });
    
    // 生日
    birthdayInput.parent().on('tap', function () {
	    dtPicker.show(function (item) {
	    	birthdayInput.text(item.text);
	    	formdata.birthday = item.text;
	    });
    });
    
    // 提交
    $('.form-submit').on('tap', function() {
    	formdata.user_realname = user_realnameInput.val().trim();
    	formdata.mobile = mobileInput.val().trim();
    	
		baseApi.post(
			'user/save',
			formdata,
			function (result) {
				userInfoUpdate(result);
				mui.toast('保存成功');
				setTimeout(function () {
					history.go(-1);
				}, 500);
		});
		return false;
    });
    
}(mui, $));
